package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseAnnouncement extends SQLiteOpenHelper {

	public String tableName = "";
	public final String ID = "_id";
	public final String AnnouncementID="AnnouncementID";
	public final String CourseCode="AnnouncementCourseCode";
	public final String Title="AnnouncementTitle";
	public final String Description ="AnnouncementDescription";
	public final String CreatedDate="AnnouncementCreatedDate";
	public final String CreatorName="AnnouncementCreatorName";
	public final String isRead="AnnouncementIsRead";
	
	public DatabaseAnnouncement(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "
				    + tableName
				  	+ " ( "
					    + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
					  	+ AnnouncementID + " TEXT UNIQUE, "
					    + CourseCode +" TEXT, " 
					  	+ Title + " TEXT, " 
					    + Description + " TEXT, " 
					  	+ CreatedDate + " TEXT, "
					    + CreatorName + " TEXT, " 
					  	+ isRead + " INTEGER"
				  	+ ")"
				  );
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
